package com.example.demo.controller;

import com.example.demo.model.Commodity;

import com.example.demo.model.ReservationVo;
import com.example.demo.server.afterServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class afterController {
    @Autowired
    public afterServer  afterServer;

    //查询所有菜品
    @GetMapping("/all")
    public String seleAll(Model model){
        List<Commodity> commodities = afterServer.seleAll();
        System.out.println(commodities);
        model.addAttribute("comm",commodities);
        return "tgls/goodsManage/goods_list";//没有页面
    }
    //查询订单
    @RequestMapping("/reseall")
    //@ResponseBody
    public String selRese(Model model){
        List<ReservationVo> reservationVos = afterServer.selRese();
        System.out.println(reservationVos);
        model.addAttribute("all",reservationVos);
        return "tgls/goodsManage/goodsType_list";
    }
  //修改状态
    @RequestMapping("/updOne")
    public String updOne( Integer id, Commodity commodity){
        int i = afterServer.updStaOne(id);
        System.out.println(i);
        return "redirect:/reseall";
    }
}
